/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('dypnsapi-intl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CheckVerificationRequest {
  code?: string(name='Code', description='The verification code.', example='1234'),
  ownerId?: long(name='OwnerId'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  serviceSid?: string(name='ServiceSid', description='The service ID that is displayed in the Phone Number Verification Service console.', example='FA00000000000001'),
  to?: string(name='To', description='The mobile phone number of the recipient. You must add the country code to the beginning of the mobile phone number. Example: 6212345\\*\\*\\*\\*01.', example='6212345****01'),
  verificationId?: string(name='VerificationId', description='The unique authentication ID that is returned by calling the StartVerification operation.', example='rJXlaR2q5LpKfREtpRPMBfDVQvELZwmBbK5yVR7gr3nLbNAcolLGPYCJaVHt/i+I'),
}

model CheckVerificationResponseBody = {
  code?: string(name='Code', description='The HTTP status code that was returned.', example='OK'),
  message?: string(name='Message', description='The message that was returned.', example='OK'),
  model?: map[string]any(name='Model', description='The data that was returned for the successful request. Example: "Model": { "phoneNumber": "", "channel": "", "verificationId": "", "status": "approved" },'),
  requestId?: string(name='RequestId', description='The ID of the request. An ID is a unique identifier that Alibaba Cloud generates for a request.', example='HF14955E-EEB5-3CE4-AE50-00F7FC8C1D62'),
  success?: string(name='Success', description='Indicates whether the request was successful. Valid values: true: The request was successful. false: The request failed.', example='true'),
}

model CheckVerificationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckVerificationResponseBody(name='body'),
}

async function checkVerificationWithOptions(request: CheckVerificationRequest, runtime: Util.RuntimeOptions): CheckVerificationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.code)) {
    query['Code'] = request.code;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.serviceSid)) {
    query['ServiceSid'] = request.serviceSid;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  if (!Util.isUnset(request.verificationId)) {
    query['VerificationId'] = request.verificationId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CheckVerification',
    version = '2017-07-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkVerification(request: CheckVerificationRequest): CheckVerificationResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkVerificationWithOptions(request, runtime);
}

model SearchVerificationRequest {
  code?: string(name='Code', description='The verification code.', example='1234'),
  currentPage?: long(name='CurrentPage', description='The number of the page to return. Pages start from page 1.', example='1'),
  ownerId?: long(name='OwnerId'),
  pageSize?: long(name='PageSize', description='The number of entries to return on each page.', example='10'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  sendDate?: long(name='SendDate', description='The time when a text message is sent, in milliseconds. You can query text messages that were sent within the last 30 days.

Example: 1677600000000.', example='1677600000000,'),
  serviceSid?: string(name='ServiceSid', description='The service ID that is displayed in the Phone Number Verification Service console.', example='FA00000000000001'),
  to?: string(name='To', description='The mobile phone number of the recipient. You must add the country code to the beginning of the mobile phone number. Example: 6212345\\*\\*\\*\\*01.', example='6212345****01'),
  verificationId?: string(name='VerificationId', description='The unique authentication ID that is returned by calling the StartVerification operation.', example='rJXlaR2q5LpKfREtpRPMBfDVQvELZwmBbK5yVR7gr3nLbNAcolLGPYCJaVHt/i+I'),
}

model SearchVerificationResponseBody = {
  code?: string(name='Code', description='The HTTP status code that was returned for the request.', example='OK'),
  message?: string(name='Message', description='The message that was returned.', example='OK'),
  model?: map[string]any(name='Model', description='The data that was returned for the request. Example: "Model": { "records": \\[ { "sendDate":, "channel": "", "serviceSid": "", "to": "", "updatedDate":, "verificationId": "", "status": "" } ], "pageNo": , "totalPage": 1, "pageSize": 20, "totalCount": 1, }'),
  requestId?: string(name='RequestId', description='The ID of the request. An ID is a unique identifier that Alibaba Cloud generates for a request.', example='HF14955E-EEB5-3CE4-AE50-00F7FC8C1D62'),
  success?: boolean(name='Success', description='Indicates whether the request was successful. Valid values: true: The request was successful. false: The request failed.', example='true'),
}

model SearchVerificationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SearchVerificationResponseBody(name='body'),
}

async function searchVerificationWithOptions(request: SearchVerificationRequest, runtime: Util.RuntimeOptions): SearchVerificationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.code)) {
    query['Code'] = request.code;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.sendDate)) {
    query['SendDate'] = request.sendDate;
  }
  if (!Util.isUnset(request.serviceSid)) {
    query['ServiceSid'] = request.serviceSid;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  if (!Util.isUnset(request.verificationId)) {
    query['VerificationId'] = request.verificationId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SearchVerification',
    version = '2017-07-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchVerification(request: SearchVerificationRequest): SearchVerificationResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchVerificationWithOptions(request, runtime);
}

model StartVerificationRequest {
  channel?: string(name='Channel', description='The channels that you can use for verification.

Valid values:

*   Voice

    <!-- -->

    <!-- -->

    <!-- -->

*   SMS

    <!-- -->

    <!-- -->

    <!-- -->

*   WhatsApp

    <!-- -->

    <!-- -->

    <!-- -->', example='SMS'),
  ownerId?: long(name='OwnerId'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  serviceSid?: string(name='ServiceSid', description='The service ID that is displayed in the Phone Number Verification Service console.', example='FA00000000000001'),
  to?: string(name='To', description='The mobile phone number of the recipient. You must add the country code to the beginning of the mobile phone number. Example: 6212345\\*\\*\\*\\*01.', example='6212345****01'),
}

model StartVerificationResponseBody = {
  code?: string(name='Code', description='The HTTP status code that was returned for the request.', example='OK'),
  message?: string(name='Message', description='The message that was returned.', example='OK'),
  model?: map[string]any(name='Model', description='The data that was returned only if the request was successful. Example: "Model": { "verifyCode": "", "verificationId": "", "status": "" }'),
  requestId?: string(name='RequestId', description='The ID of the request. An ID is a unique identifier that Alibaba Cloud generates for a request.', example='HF14955E-EEB5-3CE4-AE50-00F7FC8C1D62'),
  success?: boolean(name='Success', description='Indicates whether the request was successful. Valid values: true: The request was successful. false: The request failed.', example='true'),
}

model StartVerificationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StartVerificationResponseBody(name='body'),
}

async function startVerificationWithOptions(request: StartVerificationRequest, runtime: Util.RuntimeOptions): StartVerificationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.channel)) {
    query['Channel'] = request.channel;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.serviceSid)) {
    query['ServiceSid'] = request.serviceSid;
  }
  if (!Util.isUnset(request.to)) {
    query['To'] = request.to;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StartVerification',
    version = '2017-07-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function startVerification(request: StartVerificationRequest): StartVerificationResponse {
  var runtime = new Util.RuntimeOptions{};
  return startVerificationWithOptions(request, runtime);
}

